Temp GR sqrtGR
1 0.7 0.00000 0.0000
2 3.4 0.00034 0.0185
3 7.6 0.00127 0.0356
4 9.6 0.00166 0.0407
5 11.2 0.00230 0.0480
6 12.8 0.00256 0.0506
Statistical Examination of Challenge Test Data and Modelling
2024-04-30
Import a .csv file to R softwareCheck a data setSelect an adequate secondary modelFit a secondary modelExamine the fitting resultsObtain the confidence and prediction intervalsR script: Unit1-ChallengeTestsDataAnalysisSGM.RGrowth rate values of salmonella in brothlisteria.csv file has three columns (Temp, GR sqrtGR) and 29 observations
Temp is the temperature used to measure the growth rateGR is the growth ratesqrtGR is the square root of the growth ratelisteria.csv with the read.csv() function and save it as data frame (df)str()) function'data.frame': 28 obs. of 3 variables:
$ Temp : num 0.7 3.4 7.6 9.6 11.2 12.8 14.1 15.4 16.9 18.2 ...
$ GR : num 0 0.00034 0.00127 0.00166 0.0023 0.00256 0.00311 0.00423 0.00452 0.00587 ...
$ sqrtGR: num 0 0.0185 0.0356 0.0407 0.048 0.0506 0.0558 0.065 0.0672 0.0766 ...
Temp: temperatureGR: growth ratesqrtGR: square root of the growth ratesqrtGR against Temperature
environmental factors on microbial growth ratesecondary model, using directly the untransformed growth rate response variable produces heterocedastic modelsadequate fitting, the growth rate values are often transformed by taking the natural logarithm or the square rootR software
freestatistical analysis and plotsfit non-linear models to experimental data
nls() function from the```stats packagegsl_nls() from gslnls package (GNU Scientific Library)R software: https://cran.r-project.org/predmicror package: https://fsqanalytics.github.io/predmicror/predmicror package from GitHub repositorypredmicror packageCardinal model for temperature implemented in the predmicror package
function (x, Tmax, Tmin, MUopt, Topt)
{
if (!requireNamespace("gslnls", quietly = TRUE)) {
stop("Package \"gslnls\" must be installed to use this function.",
call. = FALSE)
}
CMT <- ifelse(x <= Tmin | x >= Tmax, 0, MUopt * (((x - Tmax) *
(x - Tmin)^2)/((Topt - Tmin) * ((Topt - Tmin) * (x -
Topt) - (Topt - Tmax) * (Topt + Tmin - 2 * x)))))
result <- sqrt(CMT)
return(result)
}
<bytecode: 0x57af77b9bab0>
<environment: namespace:predmicror>
non-linear models we need to we need to supply starting values for the model parametersCMTI model to the experimental datalibrary(predmicror)
library(gslnls)
fit <- gsl_nls(sqrtGR ~ CMTI(Temp,Tmax,Tmin,MUopt,Topt),
data=df,
start = start.values
)
fitNonlinear regression model
model: sqrtGR ~ CMTI(Temp, Tmax, Tmin, MUopt, Topt)
data: df
Tmax Tmin MUopt Topt
44.27284 1.38405 0.02139 37.33238
residual sum-of-squares: 0.000484
Algorithm: multifit/levenberg-marquardt, (scaling: more, solver: qr)
Number of iterations to convergence: 6
Achieved convergence tolerance: 3.619e-09
summary() function
Formula: sqrtGR ~ CMTI(Temp, Tmax, Tmin, MUopt, Topt)
Parameters:
Estimate Std. Error t value Pr(>|t|)
Tmax 4.427e+01 6.121e-02 723.351 <2e-16 ***
Tmin 1.384e+00 5.564e-01 2.488 0.0202 *
MUopt 2.139e-02 4.531e-04 47.211 <2e-16 ***
Topt 3.733e+01 3.157e-01 118.245 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.004491 on 24 degrees of freedom
Number of iterations to convergence: 6
Achieved convergence tolerance: 3.619e-09
coef() functionconfint() functionpredict() function to compute the prediction intervalfits <- predict(fit,
newdata = data.frame(Temp=new.temp),
interval = "prediction", level = 0.95)
str(fits) num [1:217, 1:3] 0 0 0 0 0.000574 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:3] "fit" "lwr" "upr"
fits objectplot() functionlines() function to add the confidence intervalShiny app CardinalFit: https://ubarron.shinyapps.io/CardinalFit/